//
//  POSProcess.h
//  HPZZTong
//
//  Created by WenJun on 14-7-8.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "HPBaseSwiper.h"


typedef NS_ENUM(int, SwipeAction)
{
    SwipeActionNone,
    SwipeActionSwipe,
    SwipeActionInputPin,
    SwipeActionEncrypt,
    SwipeActionCalMac,
};

@class SwipeInfo;

@protocol POSProcessDelegate <NSObject>

- (void)process:(id)process finishedWithResult:(HPSwiperResult *)result;//通知结果
@optional
- (void)notifyReSwipe:(id)process result:(HPSwiperResult *)result;//通知刷卡失败,调用reswipe重刷
- (BOOL)process:(id)process didGetSwipeInfo:(SwipeInfo *)swipeInfo;//返回NO 外部可中断流程 调用continue方法继续
- (BOOL)inputPwdFinished:(id)process;//返回NO 外部可中断流程 调用continue方法继续

- (void)notifySwipe:(id)process;//通知刷卡
- (void)notifyInputPin:(id)process appInput:(BOOL)appInput;//通知输入密码

- (void)selectApplication:(id)process result:(HPSwiperResult *)result;
@end


@protocol POSProcessUIDelegate <NSObject>
@required
-(void)processSelectApp:(NSArray*)kindsOfPOSDevice;
@end

@protocol HPSwipeServiceProtocal;

//自动完成 刷卡-输入密码-加密-计算mac
@interface POSProcess : NSObject

@property (weak,nonatomic) id delegate;
@property (weak,nonatomic) id uiDelegate;
@property (weak,nonatomic) HPBaseSwiper * currentSwiper;
//当前执行的刷卡器操作
@property (readonly,nonatomic) SwipeAction currentAction;
//外部赋值金额
@property (strong,nonatomic) NSString * plainAmount;
//自动形成的属性
@property (readonly,nonatomic) NSString * factor;
@property (readonly,nonatomic) NSString * csn;
@property (readonly,nonatomic) NSString * time;
@property (readonly,nonatomic) SwipeInfo * swipeInfo;
@property (readonly,nonatomic) NSString * encAccount;
@property (readonly,nonatomic) NSString * encAmount; //有金额才会有
@property (readonly,nonatomic) NSString * encPin;
@property (readonly,nonatomic) NSString * encMac;
@property (readonly,nonatomic) BOOL icMode;
@property (nonatomic, weak) id<HPSwipeServiceProtocal> swipeService;

- (void)beginWithDelegate:(id)delegate;
- (void)dealResult:(HPSwiperResult *)result;
- (void)pinInputed:(NSString *)plainPin;//ui调用 app键盘输入完调用
- (NSString *)joinMac;//子类覆盖，如果无需计算mac 返回nil，不实现则默认mac处理
- (void)reSwipe;//ui调用
- (void)continueAction;//ui调用
- (void)clear;//放弃操作

@end
